namespace KMS.Core
{
    using System;
    using System.Diagnostics;

    [Serializable]
    public abstract class EntityValidateAttribute : Attribute
    {
        internal Exception GetError(object entity)
        {
            Exception ret = null;
            try
            {
                this.Valid(entity);
            }
            catch (Exception ex)
            {
                ret = new Exception("Validation Error.", ex);
                Trace.TraceWarning(string.Format("validation error. refer to the inner exception. {0}", ex.Message));
            }
            return ret;
        }
        public abstract void Valid(object entity);
    }
}